<template>
  <div class="container">
    <a-row>
      <a-col :span="24">
        <a-space>
          <a-popconfirm content="确认同步吗?" @ok="tongBu">
            <a-button type="primary" status="danger"><template #icon><icon-redo /></template>同步</a-button>
          </a-popconfirm>
        </a-space>
      </a-col>
    </a-row>
    <a-table :bordered="{cell:true}" :pagination="false" stripe :data="state.logObj.list">
      <template #columns>
        <a-table-column title="同步状态" data-index="statusname" width="100"></a-table-column>
        <a-table-column title="同步时间" width="180">
          <template #cell="{ record }"><DateFormat :value="record.updateTime" :format="'YYYY-MM-DD HH:mm:ss'"></DateFormat></template>
        </a-table-column>
        <a-table-column title="日志描述" data-index="logcontent"></a-table-column>
      </template>
    </a-table>
    <a-pagination class="mt10" show-total :total="state.logObj.total" @change="loadLog" @page-size-change="loadLog" v-model:current="state.sd.pageNum" v-model:page-size="state.sd.pageSize"></a-pagination>
  </div>
</template>

<script lang="ts" setup>
import axios from "axios";
import { Message } from '@arco-design/web-vue'
import {reactive, ref, onMounted, onUnmounted, defineAsyncComponent} from "vue";

const state = reactive({
  sd: {
    pageNum: 1,
    pageSize: 15
  },
  logObj: {},
})

const loadLog = ()=>{
  axios.post('/busslog/pagewuliaotongbulog', state.sd).then(res => {
    const { data } = res
    state.logObj = data
  })
}
const tongBu = ()=>{
  axios.post('/bussoper/wuliaotongbu', {}).then(res => {
    const { code } = res
    if(code === '200'){
      Message.info("已执行同步操作,请查看同步日志")
      state.sd.pageNum = 1;
      loadLog();
    }
  })
}
onMounted(()=>{
  loadLog();
})
</script>

<style scoped>

</style>
